# Maintainer: Christian Hesse <mail@eworm.de>

pkgname=perl-dbd-mariadb
pkgver=1.23
pkgrel=1
pkgdesc='MariaDB and MySQL driver for the Perl5 Database Interface (DBI)'
arch=('loong64' 'x86_64')
license=('GPL' 'PerlArtistic')
url='https://metacpan.org/release/DBD-MariaDB'
depends=('mariadb-libs' 'perl-dbi')
makedepends=('perl-devel-checklib')
checkdepends=('mariadb' 'perl-test-deep')
source=("https://cpan.metacpan.org/authors/id/P/PA/PALI/DBD-MariaDB-${pkgver}.tar.gz")
sha512sums=('2217f36606caab477b8fa931a69b53b7f706a25cf013e4b62aa1b0b48905aba24b724604b4b99e83dea08d967848119447f35ff8e6b5eb80c7fea4e8c084de16')

build() {
  cd DBD-MariaDB-${pkgver}

  perl Makefile.PL INSTALLDIRS=vendor --testsocket=/tmp/socket.mysql
  make
}

check() {
  cd DBD-MariaDB-${pkgver}

  mkdir -p /tmp/mysql_test
  mariadb-install-db \
     --basedir=/usr \
     --datadir=/tmp/mysql_test
  mariadbd -P 17999 \
     --socket=/tmp/socket.mysql \
     --datadir=/tmp/mysql_test &
  sleep 10
  DAEMON_PORT=$!
  make test
  kill -9 $DAEMON_PORT
}

package() {
  cd DBD-MariaDB-${pkgver}

  make install DESTDIR="${pkgdir}"
}
